/************************************************************************/
/* gaoxinglong @xspeech                                                 */
/************************************************************************/
#ifndef _kaldi_scp_process_h_
#define _kaldi_scp_process_h_
#include <string>
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <thread>
#include <sstream>
#include <mutex>
#include <atomic>
using namespace std;



class StdThread
{
public:
	StdThread();
	~StdThread();
	bool Enter();
	bool Leave();

private:
	std::mutex stream_mtx;
	

};






class KaldiScpProcess
{

public:
	KaldiScpProcess(const char* kaldi_scp_file);
	~KaldiScpProcess();

	ifstream& OpenKaldiScpFile(const char* kaldi_scp_file = nullptr /*if nullptr, we open default scp file*/);
	inline bool IsKaldiScpFileOpen(){
		return mIs.is_open();
	}
	const std::set<string>& get_all_keys();
	inline const std::vector<string>& get_sequence_keys(){
		return mAllkeyAarray;
	}



private:
	inline void EnterStream(){
		stream_guard.Enter();
	}
	inline void LeaveStream(){
		stream_guard.Leave();
	}


private:
	string mKaldi_scp_file;
	//////////////////// we should define some vars about thread[c++11]  start //////////////////////////
	ifstream mIs;
	std::set<string> mAllkeys;
	std::vector<string> mAllkeyAarray;
	StdThread stream_guard;


	//////////////////// we should define some vars about thread[c++11] end /////////////////////////////

}; //end of class


int ProcessKaldiScp(const KaldiScpProcess& task_info);
string FixPdf(const char* pdf_entry);
string FixPdfContent(const char* pdf_content);

#endif